//
//  NSNull+CLSafety.m
//  SpartanMini
//
//  Created by Charlie Liao on 16/4/23.
//  Copyright © 2016年 Charlie Liao. All rights reserved.
//

#import "NSNull+CLSafety.h"

/// 判断是否为空
BOOL objIsNotNull(NSObject* obj) {
    return (obj != nil && ![obj isKindOfClass:NSNull.class]);
}

/// 安全取值，把NSNull类型转换掉
id toSafeObject(NSObject* unSafeObj) {
    if ([unSafeObj isKindOfClass:NSNull.class]) {
        return nil;
    }
    return unSafeObj;
}

@implementation NSNull (CLSafety)

- (id)objectAtIndex:(NSUInteger)index {
    return nil;
}

- (id)objectForKey:(NSString *)key {
    return nil;
}

- (NSInteger)integerValue {
    return 0;
}

- (NSUInteger)unsignedIntegerValue {
    return 0;
}

- (int)intValue {
    return 0;
}

- (long long)longLongValue {
    return 0;
}

- (float)floatValue {
    return 0;
}

- (double)doubleValue {
    return 0;
}

- (BOOL)boolValue {
    return NO;
}

- (NSInteger)length {
    return 0;
}

- (BOOL)isEqualToString:(NSString *)aString {
    return NO;
}

- (BOOL)isEqualToValue:(NSValue *)value {
    return NO;
}

- (BOOL)isEqualToNumber:(NSNumber *)number {
    return NO;
}

@end
